package com.ruoyi.common.client;

import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.DataVariable;
import com.dtflys.forest.annotation.Get;
import com.dtflys.forest.annotation.Post;
import com.ruoyi.common.vo.WeChatPhoneNumberResponse;
import com.ruoyi.common.vo.WeChatTokenResponse;

/**
 * 获取微信小程序接口
 * @author zhangcunlei
 */
public interface WeChatClient {
    
    /**
     * 微信小程序获取 token
     * @return 数据
     */
    @Get(url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=${0}&appid=${1}&secret=${2}", dataType = "json")
    WeChatTokenResponse getAccessToken(String grantType, String appid, String secret);

    /**
     * 微信小程序获取手机号
     * @return 数据
     */
    @Post(
            url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=${accessToken}",
            headers = {
                    "Accept:text/plain",
                    "Accept-Charset: utf-8",
                    "content-type: application/json"
            }
    )
    WeChatPhoneNumberResponse getPhoneNumber(@DataVariable("accessToken") String accessToken, @Body("code") String code);

}